using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;

namespace Elephant.Framework
{
    /// <summary>
    /// Tagged on a component to specify which components it depends on. 
    /// This ensures that the specified component dependencies will always be contained in the component's owner.
    /// </summary>
    /// <remarks>
    /// A common example would be that a Render component is dependent on a Transform, so that it knows "where" to render its contents.
    /// </remarks>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class ComponentDependency : Attribute
    {
        Type[] dependencies;

        public ComponentDependency(params Type[] args)
        {
            dependencies = args;
        }

        public Type[] Dependencies
        {
            get
            {
                return dependencies;
            }
        }
    }

    // following was a great solution, so we could specify dependencies by giving the type and whatever parameters we wanted to call it with
    // sadly, C# limitations on attributes result in this:
    //
    // Error	1	An attribute argument must be a constant expression, typeof expression or array creation expression
    //
    // this is how I had imagined it would be:
    //    [ComponentDependency(
    //          new Dependency(typeof(Transform), Vector3.Zero))] // add a transform with Vector3.Zero passed as a parameter (initial position)

    /*
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class NewComponentDependency : Attribute
    {
        Dependency[] dependencies;

        public NewComponentDependency(params Dependency[] args)
        {
            dependencies = args;
        }

        public Dependency[] Dependencies
        {
            get
            {
                return dependencies;
            }
        }
    }
    
    public class Dependency
    {
        Type type;
        object[] parameters;

        public Dependency(Type type, params object[] parameters)
        {
            this.type = type;
            this.parameters = parameters;
        }

        public Type Type
        {
            get
            {
                return type;
            }
        }

        public object[] Parameters
        {
            get
            {
                return parameters;
            }
        }
    }*/
}
